package com.eshop.common.web.vo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.Collections;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiModel;
import java.io.Serializable;

@ApiModel("分页")
public class Paging<T> implements Serializable
{
    private static final long serialVersionUID = -1683800405530086022L;
    @ApiModelProperty("总行数")
    @JSONField(name = "total")
    @JsonProperty("total")
    private long total;
    @ApiModelProperty("数据列表")
    @JSONField(name = "records")
    @JsonProperty("records")
    private List<T> records;
    
    public Paging() {
        this.total = 0L;
        this.records = Collections.emptyList();
    }
    
    public Paging(final IPage page) {
        this.total = 0L;
        this.records = Collections.emptyList();
        this.total = page.getTotal();
        this.records = (List<T>)page.getRecords();
    }
    
    public long getTotal() {
        return this.total;
    }
    
    public void setTotal(final long total) {
        this.total = total;
    }
    
    public List<T> getRecords() {
        return this.records;
    }
    
    public void setRecords(final List<T> records) {
        this.records = records;
    }
    
    @Override
    public String toString() {
        return "Paging{total=" + this.total + ", records=" + this.records + '}';
    }
}
